package com.yb.guigu.pick.security.util;

import com.yb.guigu.pick.security.bean.GuiguAbstractAuthenticationToken;
import com.yb.guigu.pick.security.bean.GuiguPickUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/6/3 17:20
 * FileName: SecurityUtil
 * Description:
 */
public class SecurityUtil {

    public static Authentication getAuthentication(){
        return SecurityContextHolder.getContext().getAuthentication();
    }


    public static GuiguPickUser getUserInfo(){
        GuiguAbstractAuthenticationToken authentication = (GuiguAbstractAuthenticationToken) getAuthentication();
        return authentication.getGuiguPickUser();
    }
}
